<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 用户输入高亮显示内容 -->
    <div id="content">houdunren.com</div>
    <script>
      const content = prompt('请输入要搜索的内容，支持正则表达式');
      const reg = new RegExp(content, 'g');
      let body = document.querySelector('#content').innerHTML.replace(reg, (str) => {
        return `<span style="color:red">${str}</span>`;
      });
      document.body.innerHTML = body;
    </script>
  </body>
</html>
